<html>
<head>
    <title>透析助手</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.6/css/sm.min.css">
    <link rel="stylesheet" href="__PUBLIC__/css/style.css">
    <link rel="stylesheet" href="__PUBLIC__/css/5s.css">
    <link rel="stylesheet" href="__PUBLIC__/css/6m.css">
    <link rel="stylesheet" href="__PUBLIC__/css/iconfont.css">
	<style>
		.personalJj{width:92.5%;border:none;font-size:0.8rem;font-weight:100;}
	</style>
</head>
<body>
	<div class="head">
		<div class="HeadContent">
			<a href="<{:U('Index/doctor')}>" class="backIndex"><i class="iconfont">&#xe605;</i></a>
			<a href="javascript:;" class="HeadTitle">个人信息</a>
		</div>
	</div>
	<div class="PersonalHead">
		<div class="PersonalHeadImg">
			<if condition="$userInfo['pic'] neq ''">
                <img src="<{$userInfo.pic}>" id="headImg" style="border-radius:50%;" />
            <else />
                <img src="__PUBLIC__/images/PersonalHeadImg.png" id="headImg" />
            </if>
		</div>
		<div class="PersonalName">
			<{$userInfo.name}>&nbsp;  <{:$userInfo['sex']==2 ? '女' : '男'}>
			<a href="<{:U('Personal/score')}>"> <span>我的积分</span> <i class="iconfont">&#xe60a;</i> </a>
		</div>
		<!--  <div class="PersonalCredits">
		<a href="#">
		<span>我的积分</span>
		<i class="iconfont">&#xe60a;</i>
		</a>
		</div> -->
	</div>
	<div class="PersonalInformation">
		<ul>
			<li>
				<a href="javascript:void(0);">
				<div class="LeftTitle">
					透析中心
				</div>
				<div class="RightContent">
					<span><{$userInfo.hpt_name}></span>
					<i class="iconfont">&nbsp;</i>
				</div> </a>
			</li>
			<li>
				<a href="javascript:void(0);">
				<div class="LeftTitle">
					手机
				</div>
				<div class="RightContent">
					<span> <{$userInfo.phone}> </span>
					<i class="iconfont">&nbsp;</i>
				</div> </a>
			</li>
			<li onclick="$('.Popwindow').show();">
				<a href="javascript:void(0);">
				<div class="LeftTitle">
					个人简介
				</div>
				<div class="RightContent">
					<span><empty name="userInfo.des">请填写<else />查看</empty></span>
					<i class="iconfont">&#xe60a;</i>
				</div>
                </a>
			</li>
		</ul>
	</div>
	<div class="Popwindow">
		<div class="PopContent">
			<div class="PopContentTitle" >
				个人简介
			</div>
			<div class="PopContentText">
				<textarea class="personalJj" id="val" placeholder="请输入您的简介"><{$userInfo.des}></textarea>
				<div class="BtnGroup Btn-Popwindow">
                    <button class="btn-drop" type="button" onclick="cancel()">取消</button>
                    <button class="btn-submit" onclick="save()">确定</button>  
				</div>
			</div>
		</div>
	</div>
    <!-- 上传照片iframe开始 -->
    <div style="visibility:hidden;width:100%;overflow-x:hidden;">
        <iframe name='img_frame' id="img_frame" style="visibility:hidden;height:1px"></iframe>
        <form id="img_form" action="<{:U('Admin/PicUpload/index')}>" encType="multipart/form-data" method="post" target="img_frame">
            <input type="file" name="pic" id="img_file" onchange="$('#img_form').submit();"/>
        </form>
    </div>
    <!-- 上传照片iframe结束 -->
    <!-- 加载动画 -->
    <div id="loadingBg" style="display:none;"></div>
<script type='text/javascript' src='__PUBLIC__/js/jquery-1.11.1.min.js'></script>
<script type='text/javascript' src='__PUBLIC__/js/myjq.js'></script>
<script type="text/javascript">
$(function(){
    //上传图片
    $("#headImg").click(function(){
        $('#loadingBg').show();
        $('#img_file').click()
    });
    $('#img_frame').load(function(){
        try{
            var iframeHtml = $(this).contents().find('body').html();
        }catch(e){
            var iframeHtml = window.frames["img_frame"].document.body.innerText;
        }
        $('#loadingBg').hide();
        var result = $.parseJSON(iframeHtml);
        if(result.msg=='suc'){
            $('#headImg').attr('src',result.url);
            editInfo('pic',result.url);//修改用户头像
        }else{
            alert(result.msg);
        }
    });
})
function cancel(){
    $('.Popwindow').hide();
    $('#val').val('<{$userInfo.des}>');
}
function save(){
    if($('#val').val() == ''){
        toast('请输入您的简介');return;
    }
    loadingShow();
    $.post('<{:U("saveDes")}>',{id:'<{$userInfo.id}>',des:$('#val').val()},function(){
        location.reload();
    })
}

//ajax修改用户信息
function editInfo(name,val){
    $.post('<{:U("Personal/editUserInfo")}>',{name:name,val:val});
}
</script>
</body>
</html>